import {
	createStore
} from "vuex";
import logo from "@/assets/logo.png";

// 创建全局变量库和全局函数创库
const store = createStore({
	// 全局变量， state 状态-变量
	state() {
		return {
			//用户信息存放
			user: {
				name: '',
				role: '',
				pic: ''
			},
			pagenum : 1,
			//错误记录
			msg: '错误提示警告框...',
			clean() {
				this.user = {
					name: '',
					role: '',
					pic: ''
				}
			},
			pic(pic) {
				let p = "http://127.0.0.1:9000/api/public/showimg/" + pic
				//中间拦截处理空属性
				if (pic == undefined || pic == '') {
					p = logo;
				}
				return p;
			}
		}
	}

})

//将组件暴露出去
export default store